;( function () {
	"use strict";
    var param_map = Result.getLocationParamObject();
    var global_param_map;
	
	$( function () {
		if(!ifUser()){
			return;
		}
		queryUserInfo();
		
		
		$('#uploadphoto').localResizeIMG({
			width: 600,
		    quality: 0.5,
		    success: function (that, result) { 
		    	var submitData = {
		    		"imgdata" : result.base64,
		    		"userId" : 	USER.userId,
		        }; 
		    	$.ajax(getAjaxOps('/user/upload', submitData)
				).done(function(res){
					if(res.resultCode == 0) {
		            	$("#user_photo").attr("src", IMG_PRE +"/"+ res.data);
		            } else {
		            	$("body").tips(res.data);
		            }
			    });
		    }
		 });
		
		//退出登录
		 $("#loginout").click(function(){
			 logout();
			 Result.forward("login.html", {});
			 return;
		 });
	}); 
	
	
	/**
	 * 获取用户信息
	 */
	function queryUserInfo(){
		var params = {
			"userId" : 	USER.userId,
		};
		$.ajax(getAjaxOps('/user/getUserInfo', params)
		).done(function(res){
			var data = res.data;
            if(res.resultCode == 0) {
            	$("#user_photo").attr("src", IMG_PRE + data.url);
            	$("#user_phone").html(data.phone);
            } else {
            	$("body").tips(res.data);
            }
	    });
	}
	
	/**
	 * 跳到首页
	 */
	window.toIndex = function(){
		Result.forward("index.html", {});
	};
	
	/**
	 * 跳到用户信息
	 */
	window.toUserInfo = function(){
		Result.forward("userInfos.html", {});
	};
	
	/**
	 * 关于我们
	 */
	window.toAboutUs = function(){
		Result.forward("aboutUs.html", {});
	};
	/**
	 * 地址管理
	 */
	window.toAddressManager = function(){
		Result.forward("addressList.html?form", {});
	};
	
	/**
	 * 跳到修改密码
	 */
	window.toResetPassword = function(){
		Result.forward("resetPassword.html", {});
	};
	
	/**
	 * 跳到绑定手机号
	 */
	window.toBindPhone = function(){
		Result.forward("bindPhone.html", {});
	};
	
	

}( window ) );
